package com.wang.yupao.once;

import java.util.Date;

import com.wang.yupao.mapper.UserMapper;
import com.wang.yupao.model.domain.User;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.Schedules;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

@Component
public class importUsers {

    @Resource
    private UserMapper userMapper;

    /**
     * 批量插入用户
     */
    public void doInsertUsers() {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        final int INSERT_NUM = 1000;
        for (int i = 0; i < INSERT_NUM; i++) {
            User user = new User();
            user.setUserName("我坤哥");
            user.setPassword("12345678");
            user.setUserAccount("tuimao");
            user.setProfile("我靠 我坤哥那么爽！！！！！");
            user.setGender(0);
            user.setPhone("123123123");
            user.setEmail("123@qq.com");
            user.setAvatar("https://3561-1303816114.cos.ap-nanjing.myqcloud.com/my-site-img/car.jpg");
            user.setStatus(0);
            user.setUserRole(0);
            user.setPlanetCode("11111111");
            user.setTags("[]");
            userMapper.insert(user);
        }
        stopWatch.stop();
        System.out.println(stopWatch.getTotalTimeMillis()); //ms
    }
}
